package com.yesep.learn.design.behavioral.strategy;

import com.yesep.learn.design.common.pojo.*;

import java.util.*;

public class StrategyA implements IStrategy {
    public final static double discount = 0.8; // 折扣

    @Override
    public String getLabel() {
        return "八折促销";
    }

    public double calculateTotalPrice(List<Goods> goodsList) {
        double totalPrice = goodsList.stream().mapToDouble(goods -> goods.getPrice() * discount).sum();
        System.out.printf("The %s %s calculate total price %s. \n", this.getClass().getSimpleName(), getLabel(), totalPrice);
        return totalPrice;
    }
}
